import { getFromLocalStorage, saveInLocalStorage } from "./store-data"

const TOKEN_PREFIX = 'Bearer '
const TOKEN        = 'token'
const AUTH         = 'Authorization'

export function setToken(token){
  saveInLocalStorage(TOKEN, token)
}

export function getToken(){
  return getFromLocalStorage(TOKEN) || {}
}

export function setAuth(config){
  config.headers.Authorization = TOKEN_PREFIX + getToken()
  return config
}

export { TOKEN, TOKEN_PREFIX, AUTH }
